﻿Module GumballMachineTestDrive
    Sub Main(ByVal args() As String)
        Dim count As Integer = 0

        If args.Length < 2 Then
            Console.WriteLine("GumballMachine <name> <inventory>")
            Return
        End If

        Try
            count = Convert.ToInt32(args(1))
        Catch ex As Exception
            Console.WriteLine(ex.StackTrace)
            Return
        End Try

        Dim gumballMachine As New GumballMachine(args(0), count)
        Dim monitor As New GumballMonitor(gumballMachine)

        Console.WriteLine(gumballMachine.ToString)

        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()
        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()

        Console.WriteLine(gumballMachine.ToString)

        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()
        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()

        Console.WriteLine(gumballMachine.ToString)

        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()
        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()

        Console.WriteLine(gumballMachine.ToString)

        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()
        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()

        Console.WriteLine(gumballMachine.ToString)

        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()
        gumballMachine.InsertQuarter()
        gumballMachine.TurnCrank()

        Console.WriteLine(gumballMachine.ToString)

        monitor.Report()
    End Sub
End Module
